/**
 * @param {string} s
 * @param {number[]} indices
 * @return {string}
*/
var restoreString = function(s, indices) {
  let result = [];
  for(let i = 0; i < indices.length; i++) {
    result[indices[i]] = s[i];
  }
  return result.join("");
};
let s = "codeleet", indices = [4,5,6,7,0,2,1,3];
console.log(restoreString(s, indices));
s = "abc", indices = [0,1,2];
console.log(restoreString(s, indices));
